define(['angular', 'app', 'ngUiRouter', 'app.services','services/common/base','directives/common/common','directives/xdd/shared'], function (angular, app,service) {

    'use strict';

    app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider,CurrentUser) {

        app.loadJs = function(js){
            return function($rootScope, $q){
                var def = $q.defer(), deps=[];
                angular.isArray(js) ? (deps = js) : deps.push(js);
                require(deps,function(){
                    $rootScope.$apply(function(){
                        def.resolve();
                    });
                });
                return def.promise;
            };
        }

        $urlRouterProvider.otherwise(function(){
            return "/common/user"
        });
        /**
         * 基础路由
         */
        $stateProvider.state("common", {
            url: "/common",
            resolve: {
                deps:app.loadJs(['directives/xdd/xdd'])
            },
            templateUrl: "/app/partial/xdd/common.html"
        });
        $stateProvider.state("common.evaluate", {//评价管理列表
            url: "/evaluate",
            template: "<evaluate-manager></evaluate-manager>"
        });
        $stateProvider.state("common.evaluateDetail", {//评价详情
            url: "/evaluate/:id",
            template: "<evaluate-detail></evaluate-detail>"
        });
        $stateProvider.state("common.goods_price", {//商品单价维护页面
            url: "/goods_price",
            template: "<goods-price></goods-price>"
        });
        $stateProvider.state("common.goods_list", {//商品列表页面
            url: "/goods_list",
            template: "<goods-list></goods-list>"
        });
        $stateProvider.state("common.goods_add", {//添加商品页面
            url: "/goods_add",
            template: "<goods-add></goods-add>"
        });
        $stateProvider.state("common.goodsUpdate", {//商品详情
            url: "/goodsUpdate/:id",
            resolve: {
                deps:app.loadJs(['fileinputLocaleZh'])
            },
            template: "<goods-update></goods-update>"
        });
        $stateProvider.state("common.goodsDetail", {//商品详情
            url: "/goodsDetail/:id",
            template: "<goods-detail></goods-detail>"
        });
        $stateProvider.state("common.oldGoods_list", {//旧物列表页面
            url: "/oldGoods_list",
            template: "<old-goods-list></old-goods-list>"
        });
        $stateProvider.state("common.oldGoods_add", {//添加旧物页面
            url: "/oldGoods_add",
            resolve: {
                deps:app.loadJs(['fileinputLocaleZh'])
            },
            template: "<old-goods-add></old-goods-add>"
        });
        $stateProvider.state("common.oldGoodsDetail", {//旧物详情
            url: "/oldGoods/:id",
            template: "<old-goods-detail></old-goods-detail>"
        });
        $stateProvider.state("common.oldGoodsUpdate", {//旧物详情
            url: "/oldGoodsUpdate/:id",
            resolve: {
                deps:app.loadJs(['fileinputLocaleZh'])
            },
            template: "<old-goods-update></old-goods-update>"
        });
        $stateProvider.state("common.old_assess", {//旧物估价
            url: "/old_assess/:id",
            template: "<old-assess></old-assess>"
        });
        $stateProvider.state("common.kfry", {//客服人员列表
            url: "/kfry",
            template: "<kfry-list></kfry-list>"
        })
        $stateProvider.state("common.kfryChatList", {//客服人员聊天
            url: "/kfry/chat",
            template: "<kfry-chat-list></kfry-chat-list>"
        })
        $stateProvider.state("common.kfryChatUserList", {//客服人员与用户聊天记录
            url: "/kfry/chat/:userId",
            template: "<kfry-chat--user-list></kfry-chat--user-list>"
        })
        $stateProvider.state("common.agreement", {//协议列表
            url: "/agreement",
            template: "<agreement-list></agreement-list>"
        })
        $stateProvider.state("common.agreementDetail", {//协议列表详情
            url: "/agreement/:id",
            template: "<agreement-detail></agreement-detail>"
        })



        $stateProvider.state("common.userList", {//用户列表
            url: "/user",
            template: "<user-list></user-list>"
        })
        $stateProvider.state("common.userDetail", {//用户详情
            url: "/user/:userId",
            template: "<user-detail></user-detail>"
        })
        $stateProvider.state("common.userUpdate", {//用户修改
            url: "/user/update/:userId",
            template: "<user-update></user-update>"
        })


        $stateProvider.state("common.roleList", {//角色列表
            url: "/role",
            template: "<role-list></role-list>"
        })
        $stateProvider.state("common.rolePermList", {//角色权限分配
            url: "/role/:roleCode",
            template: "<role-perm-list></role-perm-list>"
        })

        $stateProvider.state("common.noticeList", {//公告列表
            url: "/notice",
            template: "<notice-list></notice-list>"
        })
        $stateProvider.state("common.noticeDetail", {//公告详情
            url: "/notice/:id",
            template: "<notice-detail></notice-detail>"
        })
        $stateProvider.state("common.noticeAdd", {//公告详情
            url: "/notice_add",
            template: "<notice-add></notice-add>"
        })
        $stateProvider.state("common.orderList", {//订单列表
            url: "/order",
            template: "<order-list></order-list>"
        })
        $stateProvider.state("common.orderDetail", {//订单详情
            url: "/order/:id",
            template: "<order-detail></order-detail>"
        })
        $stateProvider.state("common.orderUpdate", {//修改信息
            url: "/order/update/:id",
            template: "<order-update></order-update>"
        });
        $stateProvider.state("common.order_courier", {//旧物估价
            url: "/order_courier/:orderId",
            template: "<order-courier></order-courier>"
        });
        $stateProvider.state("common.dicList", {//字典列表
            url: "/dic",
            template: "<dic-list></dic-list>"
        })
        $stateProvider.state("common.couponList", {//优惠券列表
            url: "/coupon/list",
            template: "<coupon-list></coupon-list>"
        })
        $stateProvider.state("common.couponSetting", {//优惠券发放
            url: "/coupon/setting/{couponId}",
            template: "<coupon-setting></coupon-setting>"
        })
        $stateProvider.state("common.translateList", {//分享列表
            url: "/translate",
            template: "<translate-list></translate-list>"
        })

        $stateProvider.state("common.analyAll", {//统计分析analyAll
            url: "/analysis/:type",
            template: "<analy-all></analy-all>",
            resolve: {
                deps:app.loadJs(['echarts'])
            }
        })

        $stateProvider.state("common.agentList", {//代理商列表
            url: "/agent/list",
            template: "<agent-list></agent-list>"
        })

        $stateProvider.state("common.messagegroupList", {//消息群发
            url: "/messagegroup/list",
            template: "<messagegroup-list></messagegroup-list>"
        })

        $stateProvider.state("common.typeoneList", {//类型列表
            url: "/typeone",
            template: "<typeone-list></typeone-list>"
        })
        $stateProvider.state("common.appPicList", {//APP首页轮播图片列表
            url: "/appPic/list",
            template: "<app-pic-list></app-pic-list>"
        })
    }]);
});